<template>
  <div>
    <div class="head">
      <div class="box">
        <div class="box-left" @click="homeChange">
          <img src="../images/lucency-logo.png" alt />
        </div>
        <div class="box-wier"></div>
        <div class="box-centent">会员中心</div>
        <div class="box-right">
          <div class="box-right-hint">
            <img src="../images/hint.png" alt />
            <div class="box-right-hint-num" v-if="msgTotal>0">{{ msgTotal>9? '···':msgTotal }}</div>
          </div>
          <p>{{ nickname }}</p>
          <div class="box-right-img">
               <img :src="avatar" alt height="100%"/>
          </div>
       
        </div>
      </div>
    </div>

    <div class="top" v-if="false">
      <div class="top-box">
        <div
          @click="routerChange('business')"
          :class=" routerName=='business'? 'top-box-action':'top-box-start'"
        >
          <p>步骤1:申请主体信息</p>
        </div>
        <div
          @click="routerChange('information')"
          :class=" routerName=='information'? 'top-box-middle':'top-box-item'"
        >
          <p>步骤2:数字人信息</p>
        </div>
        <div
          @click="routerChange('payment')"
          :class=" routerName=='payment'? 'top-box-middle':'top-box-item'"
        >
          <p>步骤3:缴费</p>
        </div>
        <div
          @click="routerChange('accomplish')"
          :class=" routerName=='accomplish'? 'top-box-selected':'top-box-item-tail'"
        >
          <p>步骤4:提交完成</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { comment_total } from "@/utils/api";
export default {
  name: "headView",
  data() {
    return {
      step: {
        startUrl: require("../images/step-start.png"),
        defaultUrl: require("../images/step.png"),
        actionUrl: require("../images/step-action.png"),
        tailUrl: require("../images/step-tail.png")
      },
      routerName: "business",
      avatar: "",
      nickname: "",
      msgTotal: "0"
    };
  },
  created() {
    //获取留言条数
    if(localStorage.getItem("token")){
      comment_total({}, res => {
        localStorage.setItem('msgTotal', res.data)
      })
    }
    console.log("头部", this.$route);
    this.avatar = localStorage.getItem("avatar");
    this.nickname = localStorage.getItem("nickname");
    this.msgTotal = localStorage.getItem("msgTotal");
    
  },
  methods: {
    routerChange(val) {
      if (val == "business") {
        if (this.$route.name == "business") {
          return false;
        } else {
          this.routerName = val;
          this.$router.push({ name: "business" });
        }
      } else if (val == "information") {
        if (this.$route.name == "information") {
          return false;
        } else {
          this.routerName = val;
          this.$router.push({ name: "information" });
        }
      } else if (val == "payment") {
        if (this.$route.name == "payment") {
          return false;
        } else {
          this.routerName = val;
          this.$router.push({ name: "payment" });
        }
      } else if (val == "accomplish") {
        if (this.$route.name == "accomplish") {
          return false;
        } else {
          this.routerName = val;
          this.$router.push({ name: "accomplish" });
        }
      }
    },
    homeChange() {
      this.$router.push({ name: "home" });
    }
  }
};
</script>

<style scoped lang="scss">
.head {
  width: 100%;
  height: 120px;
  background-color: #3a7bd8;
}
.box {
  max-width: 1920px;
  min-width: 1440px;
  height: 120px;
  margin: auto;
  display: flex;
  &-left {
    // padding-left: 2.1%;
    padding-left: 50px;
    display: flex;
    align-items: center;
    vertical-align: middle;
    width: 29.4%;
    height: 120px;
    cursor: pointer;

    > img {
      width: 100%;
    }
  }
  &-centent {
    width: 20%;
    // margin-left: 1.6%;
    // padding-left: 1.6%;
    // border-left: 1px solid #ffffff;
    height: 60px;
    margin-top: 30px;
    display: flex;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
    color: #ffffff;
    letter-spacing: 3px;
  }
  &-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    &-hint {
      // width: 34px;
      // height: 40px;
      margin-right: 20px;
      position: relative;
      cursor: pointer;
      > img {
        width: 21px;
        height: 23px;
      }
      &-num {
        width: 23px;
        height: 23px;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: red;
        position: absolute;
        border-radius: 50%;
        font-size: 12px;
        font-weight: 500;
        color: #ffffff;
        top: -8px;
        right: -13px;
        border: 3px solid #3c7dd8;
      }
    }

    > p {
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
      cursor: pointer;
    }

    &-img {
      width: 60px;
      height: 60px;
      border-radius: 50%;
      cursor: pointer;
      margin-left: 20px;
      cursor: pointer;
      margin-right: 60px;
      // outline: 2px solid red;
      overflow: hidden;
    }
  }
}

.top {
  width: 100%;
  height: 160px;
  // box-shadow: 1px 1px 18px 0px rgba(207, 2, 37, 0.11);
  background-color: #ffffff;
  border-bottom: 1px solid rgba(87, 87, 87, 0.1);
  &-box {
    width: 73%;
    min-width: 1022px;
    height: 160px;
    margin: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    &-start {
      width: 307px;
      height: 61px;
      background: url("../images/step-start.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #999999;
    }
    &-item {
      width: 307px;
      height: 61px;
      background: url("../images/step.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #999999;
      &-tail {
        width: 307px;
        height: 61px;
        background: url("../images/step-tail.png");
        background-size: 100% 100%;
        background-position: center;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 18px;
        font-weight: 400;
        color: #999999;
      }
    }
    &-middle {
      width: 307px;
      height: 61px;
      background: url("../images/step-middle.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
    }
    &-action {
      width: 307px;
      height: 61px;
      background: url("../images/step-action.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
    }
    &-selected {
      width: 307px;
      height: 61px;
      background: url("../images/step-tail-action.png");
      background-size: 100% 100%;
      background-position: center;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 18px;
      font-weight: 400;
      color: #ffffff;
    }
  }
}
.box-wier {
    width: 1px;
    height: 51px;
    background-color: rgba(247, 244, 244, 0.1);
    margin-top: 35px;
    margin-left: 1.6%;
    margin-right: 1.6%;
  }
</style>
